# 51单片机程序Makefile

# 编译器设置
CC = keilc51
TARGET = main
OBJ = main.obj led_demo.obj
HEX = $(TARGET).hex

# 编译选项
CFLAGS = --code 0 --xdata 0 --model small

# 目标: 编译生成hex文件
all: $(HEX)

# 链接生成hex文件
$(HEX): $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) -o $(HEX)

# 编译main.c
main.obj: main.c led_demo.h
	$(CC) $(CFLAGS) -c main.c

# 编译led_demo.c
led_demo.obj: led_demo.c led_demo.h
	$(CC) $(CFLAGS) -c led_demo.c

# 清理生成的文件
clean:
	rm -f *.obj *.hex *.lst *.map

# 伪目标
.PHONY: all clean